using Microsoft.EntityFrameworkCore;
using Mysql.Model;
namespace Mysql.Hickey;

public class Elrost<T>(Wode db) : IRepost<T> where T : class
{
    public readonly Wode _db = db;
    public readonly DbSet<T> _td = db.Set<T>();

    public async Task<List<T>> GetAll()
    {
        var List =await _db.Set<T>().ToListAsync();
        return List;
    }

    public async Task<T?> GetByAll(Guid id)
    {
        return await _td.FindAsync(id);
    }

    public async Task<T> PastAsync(T entity)
    {
        var obj =_db.Set<T>().Add(entity).Entity;
        await _db.SaveChangesAsync();
        return obj;
    }

    public async Task PutAsync(T entity)
    {
       _td.Update(entity);
       await _db.SaveChangesAsync();
    }

    public async Task DelAsync(T entity)
    {
        _td.Remove(entity);
        await _db.SaveChangesAsync();
    }
}